package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.Shop;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QShop is a DSLite query type for Shop
 * @see Shop
 */
public class QShop extends QEntityBase<Shop> {

    public static final QShop $ = new QShop("SHOP");

    public final StringColumn sn = varchar("SN", 16).field("sn").notNull().build();

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final StringColumn tel = varchar("TEL", 16).field("tel").build();

    public final StringColumn address = varchar("ADDRESS", 64).field("address").build();

    public final StringColumn brandId = varchar("BRAND_ID", 22).field("brandId").build();

    public class Indexs {

        public final Index constraintIndex2 = index("CONSTRAINT_INDEX_2").unique().column(sn).build();

        public final Index constraintIndex26 = index("CONSTRAINT_INDEX_26").column(brandId).build();

        public final Index primaryKey2 = index("PRIMARY_KEY_2").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint26d = foreignKey(brandId, "BRAND", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShop(String tableName) {
        super(Shop.class, tableName);
    }

    @Override
    public Shop newEntity() {
        return new Shop();
    }

    @Override
    public Object getFieldValue(Shop entity, String fieldName) {
        switch (fieldName) {
            case "sn":
                return entity.getSn();
            case "name":
                return entity.getName();
            case "tel":
                return entity.getTel();
            case "address":
                return entity.getAddress();
            case "brandId":
                return entity.getBrandId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(Shop entity, String fieldName, Object value) {
        switch (fieldName) {
            case "sn":
                entity.setSn((java.lang.String) value);
                break;
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "tel":
                entity.setTel((java.lang.String) value);
                break;
            case "address":
                entity.setAddress((java.lang.String) value);
                break;
            case "brandId":
                entity.setBrandId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

